// 求一批整数中出现次数最多的各位数字
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int n;
    if (scanf("%d", &n) != 1) {
        return 0;
    }
    if (n <= 1 || n > 1000) {
        // 越界输入不输出
        return 0;
    }

    int cnt[10] = {0};
    for (int i = 0; i < n; ++i) {
        long long x;
        if (scanf("%lld", &x) != 1) {
            return 0;
        }
        if (x == 0) {
            cnt[0]++;
            continue;
        }
        long long v = llabs(x);
        while (v > 0) {
            cnt[v % 10]++;
            v /= 10;
        }
    }

    int maxc = 0;
    for (int d = 0; d <= 9; ++d) {
        if (cnt[d] > maxc) maxc = cnt[d];
    }

    int first = 1;
    for (int d = 0; d <= 9; ++d) {
        if (cnt[d] == maxc) {
            if (!first) printf(" ");
            printf("%d", d);
            first = 0;
        }
    }

    return 0;
}